<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>transfer-helper</title>

<script type="text/javascript">
	function createElementP(inner) {
		var p = document.createElement("p");
		p.innerHTML = inner;
		document.body.appendChild(p);
	}

	function readyUpload(flag) {
		var ws = new WebSocket("ws://localhost:8081/transfer-helper/ReadyUpload");
		ws.onopen = function() {
			createElementP("Websocket open!");
		}
		ws.onmessage = function(evt) {
			createElementP("Websocket message: " + evt.data);
			if(evt.data=="StartUpload"){
				document.getElementById("fileForm").submit();
			}
			else{
				document.getElementById("uploadFileID").value=evt.data;
			}
		}
		ws.onclose = function() {
			createElementP("Websocket close!");
		}
	}
</script>
</head>
<body>
	<a href="SpringServlet">getTest</a>
	<br>
	<a href="DownloadTest">DownloadTest</a>
	<br>
	<form id="fileForm" action="UploadFile" method="post" enctype="multipart/form-data">
		<input id="uploadFileID" type="hidden" name="fileID">
		<input type="file" name="uploadfile">
	</form>
	<button onclick="readyUpload()">Ready Upload</button>
	<br>
	<form action="DownloadFile" method="get">
		<input type="text" name="fileID"> 
		<input type="submit" value="DownloadFile">
	</form>
</body>
</html>